package net.lqy.aipan.exception;

import lombok.Data;
import net.lqy.aipan.enums.BizCodeEnum;

/**
 * @title: BizException
 * @Author lqy
 * @Date: 2025-05-30 12:25
 * @Version 1.0
 */
@Data
public class BizException extends  RuntimeException{
    private int code;
    private String msg;
    private String detail;

    public BizException(Integer code, String message) {
        super(message);
        this.code = code;
        this.msg = message;
    }

    public BizException(BizCodeEnum bizCodeEnum) {
        super(bizCodeEnum.getMessage());
        this.code = bizCodeEnum.getCode();
        this.msg = bizCodeEnum.getMessage();
    }

    public BizException(BizCodeEnum bizCodeEnum, Exception e) {
        super(bizCodeEnum.getMessage());
        this.code = bizCodeEnum.getCode();
        this.msg = bizCodeEnum.getMessage();
        this.detail = e.toString();
    }
}
